using System;
using Microsoft.WowAddonStudio.Lua.RuntimeService.WowBench.Resolvers;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.WowBench.Resolvers
{
	/// <summary>
	/// 
	/// </summary>
	public sealed class ResolverFactory : IResolverFactory
	{
		private readonly IServiceProvider provider;


		/// <summary>
		/// Initializes a new instance of the <see cref="ResolverFactory"/> class.
		/// </summary>
		/// <param name="provider">The provider.</param>
		public ResolverFactory(IServiceProvider provider)
		{
			this.provider = provider;
		}


		/// <summary>
		/// Creates the command resolver.
		/// </summary>
		/// <returns></returns>
		public ICommandResolver CreateCommandResolver()
		{
			return CreateResolver(ResolverType.Command);
		}


		/// <summary>
		/// Creates the expression resolver.
		/// </summary>
		/// <returns></returns>
		public ICommandResolver CreateExpressionResolver()
		{
			return CreateResolver(ResolverType.Expression);
		}


		/// <summary>
		/// Creates the resolver.
		/// </summary>
		/// <param name="resolverType">Type of the resolver.</param>
		/// <returns></returns>
		public ICommandResolver CreateResolver(ResolverType resolverType)
		{
			switch (resolverType)
			{
				case ResolverType.Command:
					return new CommandResolver(provider);
				case ResolverType.Expression:
					return new ExpressionResolver(provider);
			}
			return null;
		}
	}
}